package concurrency;

/**
 * @Auther DRevelation
 * @Date 2020-06-10 上午 9:24
 * @Desc
 */
public class InterruptedDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread threadOne = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("thread will sleep 200s");
                try {
                    Thread.sleep(200000);
                } catch (InterruptedException e) {
                    System.out.println("thread is interrupted while sleeping");
                }
            }
        });
        threadOne.start();

        Thread.sleep(1000);

        threadOne.interrupt();

        threadOne.join();

        System.out.println("main thread is over");
    }
}
